import re

class FuzzMatching():
    '''
    对文本文件进行模糊查询
    '''

    def matching(self, applications, projectName):
        FuzzData = []
        matchNames = []
        applicationNames = []
        for name in applications:
            applicationNames.append(name.get('name'))
        pattern = '.*'.join(projectName)
        regex = re.compile(pattern)
        for item in applicationNames:
            match = regex.search(item)
            if match:
                matchNames.append(item)
        for line in applications:
            if line.get('name') in matchNames:
                FuzzData.append(line)
        return FuzzData